import React from 'react'
import { Text, View, TextInput, Image, ScrollView, ImageBackground } from 'react-native'
import { Metrics, Colors, Fonts } from '../../Themes'
import { API, WINDOW } from '../../Services'
import styles from '../Styles/CommonContainerStyles'
import { Button, WingBlank } from '@ant-design/react-native'
class RenZhengScreen extends React.Component {

    constructor(props) {
        super(props)
        this.state = {
        }
    }

    addExtensionUser() {
        const { mobile } = this.state
        if (!mobile) {
            return WINDOW.showToast('手机号不能为空！')
        }
        let key = WINDOW.showToastLoad()
        API.indexName().then((response) => {
            WINDOW.hideToast(key)
            const { ok, data } = response
            if (typeof (data) == 'object') {
                if (ok) {
                    WINDOW.showToast('邀请成功')
                    this.props.navigation.popToTop()
                } else {
                    WINDOW.showToastError(data.msg || '请求失败！')
                }
            } else {
                this._fetch_indexName()
            }

        })
    }

    render() {
        return (
            <View style={styles.container}>
                <Image source={require('../../Images/yaoqingbeijing.png')} style={{ position: 'absolute', resizeMode: 'cover', width: Metrics.screenWidth, height: Metrics.screenHeight + Metrics.navBarHeight }} />
                <ScrollView >
                    <ImageBackground source={require('../../Images/yaoqing.png')} style={{ marginTop: 160, alignSelf: 'center', alignItems: 'center', width: 288, height: 404 }}>
                        <Text style={{ fontSize: 14, color: '#666666', marginTop: 188 }}>请输入邀请人手机号</Text>
                        <TextInput
                            style={{ width: 288 - 24, height: 36, backgroundColor: '#EBF0FF', borderRadius: 6, marginTop: 25, textAlign: 'center' }}
                            fontSize={14}
                            clearButtonMode='always'
                            placeholder='请输入邀请人手机号'
                            onChangeText={(mobile) => {
                                this.setState({ mobile })
                            }}
                        />
                        <View style={{ marginTop: 50, width: 200 }}>
                            <Button type='primary' size='large' onPress={() => this.addExtensionUser()}>提交</Button>
                        </View>
                    </ImageBackground>
                </ScrollView>
            </View>
        )
    }
}


export default RenZhengScreen
